import { createApp } from 'vue'
import App from './App.vue'
import store from "./store"
import router from "./router";
import Particles from "vue3-particles"
import * as utils from "./assets/common/utils"
import * as ElementPlusIconsVue from "@element-plus/icons-vue"
import echarts from "./assets/common/echarts"
import axios from "./assets/common/request"
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import { baseUrl,imgUrl } from "/public/static/config"

import logo from "./assets/images/logo.png"
import defaultAvatar from "./assets/images/default-avatar.jpg"

import addDynamicRoute from "@/router/addDynamicRoute";


import vue3TreeOrg from 'vue3-tree-org';
import "vue3-tree-org/lib/vue3-tree-org.css";

const app = createApp(App);
for (const [key,component] of Object.entries(ElementPlusIconsVue)){
    app.component(key, component)
}

// 全局挂载
app.config.globalProperties.$util = utils;
app.config.globalProperties.$echarts = echarts;
app.config.globalProperties.$urls = baseUrl
app.config.globalProperties.imgUrl = imgUrl
app.config.globalProperties.logoUrl = logo
app.config.globalProperties.defaultAvatar = defaultAvatar
app.config.globalProperties.$axios = axios;



const init = async () =>{
    const token = localStorage.getItem("token");
    if(token){
        await addDynamicRoute()
    }
    app.use(ElementPlus).use(vue3TreeOrg)
    app.use(store).use(router).use(Particles).mount("#app")
}

init();